from app import app, db, Category

with app.app_context():
    # 检查是否已有分类
    existing_categories = Category.query.count()
    if existing_categories == 0:
        # 添加默认分类
        default_category = Category(
            name='通用分类',
            description='默认的通用分类'
        )
        db.session.add(default_category)
        db.session.commit()
        print('已添加默认分类')
    else:
        print(f'已有 {existing_categories} 个分类，无需添加默认分类') 